#!/usr/bin/env bash
echo "remove exsit ip.txt"
rm -rf ./ip.txt
ym="www.baidu.com"
net_drivce="eth0"
for net in $net_drivce
do
echo "begin ping" $net
ip=`ping -I $net -c1 $ym |awk -F '[ )(]' 'NR ==1 {print $4}'`
echo "write ip:"$ip
echo "$ip" >> ip.txt
done
echo 'ip list:'
echo `cat ./ip.txt`